import re
from collections import defaultdict
import sys


logfile = sys.argv[1]
print(logfile)

# s = "2016-11-20 23:59:50.1040 INFO MessageCount:338";

# m = re.match(r".*MessageCount:(\d+)", s)
# print(m.group(1))
# p = r"MessageCount:(\d+)"
# p = re.compile(r'MessageCount:(\d+)')

ms_cnt = set()
lines = []
log = defaultdict(lambda: '')
with open(logfile, "r", encoding = "gbk") as f:
	for line in f.readlines():
		lines.append(line)
	# d = f.read()
index = 0
for l in lines:
	index = index + 1
	m = re.match(r"(.*) INFO MessageCount:(\d+)", l)
	if(m):
		cnt = m.group(2)
		t = m.group(1)
		val = log["cnt_" + cnt];
		if not val:
			info = {}
			info["cnt"] = cnt
			info["time"] = t
			log["cnt_" + cnt] = info

		ms_cnt.add(cnt)
		# print("line:", index, "find:", m.group(1))
		



# print(len(ms_cnt), ms_cnt)
# print(ms_cnt)
for key in log:
	print(log[key])





